package com.example.admin.config;

import com.example.admin.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器             拦截器名字，跟注入的名字一致
       registry.addInterceptor(tokenInterceptor)
               //要拦截哪个路径    /**是把所有的东西全部拦下
               .addPathPatterns("/**")
               //放行哪个路径            拦下含有login的路径
               .excludePathPatterns("/**/login/**");
    }
}
